package cn.htsyb.synergy.maker.util;

public class HumpUtil {

    /**
     * 将字符全部转换为小写后，将字段中指定字符替换掉，并将后续字符首字符大写拼接
     *
     * @param content
     * @param transChar
     * @return
     */

    public static String convertDumpCharToSmallHump(String content, String... transChar) {
        if (transChar != null && content != null) {
            String[] sourceSplit = content.split("[" + String.join("|", transChar) + "]");
            StringBuffer strBuff = new StringBuffer();
            for (String splitStr : sourceSplit) {
                strBuff.append(strBuff.length() == 0 ? splitStr : upperFirstChar(splitStr));
            }
            return strBuff.toString();
        } else {
            return content;
        }
    }

    /**
     * 转换为小驼峰
     */
    public static String convertToSmallHump(String content, String... dumpChar) {
        return convertDumpCharToSmallHump(content, dumpChar);
    }

    /**
     * 首字符大写
     *
     * @param content 目标字符串
     * @return 首字符大写字符串
     */
    public static String upperFirstChar(String content) {
        /*char[] cs = content.toCharArray();
        cs[0] -= 32;
        return String.valueOf(cs);*/
        return content.substring(0, 1).toUpperCase().concat(content.substring(1));
    }

    /**
     * 首字符小写
     *
     * @param content 目标字符串
     * @return 首字符小写字符串
     */
    public static String lowerFirstChar(String content) {
        return content.substring(0, 1).toLowerCase().concat(content.substring(1));
    }
}
